@using BlazorApp.Pages.Common.Html.HTable
@using BlazorApp.Pages.Common.Metadata
@using BlazorApp.Utils
@using k8s.Models
@inherits BlazorApp.Pages.Common.PageBase

@if (Volume.PersistentVolumeClaim != null)
{
    <BadgeRibbon Text="@Volume.Name" Placement="start" Color="#832">
        <TextTemplate>
            <span style="color:#DCDCDC">@Index</span>
            <Icon Type="hdd" Theme="outline"/>
            @Volume.Name
        </TextTemplate>
        <ChildContent>
            <Card Bordered>
                <HTable >
                    <HTr>
                        <HTd>
                            @L["Volume"]
                            <KubectlExplainButton Field="pod.spec.volumes.persistentVolumeClaim"></KubectlExplainButton>
                        </HTd>
                        <HTd >
                            <RefView Ref="@TransferToRef(Volume)" FullView="true"></RefView>
                        </HTd>
                    </HTr>
                </HTable>
            </Card>
        </ChildContent>
    </BadgeRibbon>
}


@code {

    [Parameter] public V1Volume Volume { get; set; }

    [Parameter] public int Index { get; set; }

    [Parameter] public string Namespace { get; set; }

    private V1ObjectReference TransferToRef(V1Volume volume)
    {
        return KubeHelper.GetObjectRef("PersistentVolumeClaim", Namespace, volume.PersistentVolumeClaim.ClaimName);
    }

}
